#include <stdio.h>
#include <stdint.h>



uint16_t str_table[16];

#define BETWEEN11(_left_,_arg_,_right_) ((_left_ <= _arg_) && (_arg_ <= _right_)) 
#define BETWEEN01(_left_,_arg_,_right_) ((_left_ <  _arg_) && (_arg_ <= _right_)) 
#define BETWEEN10(_left_,_arg_,_right_) ((_left_ <= _arg_) && (_arg_ <  _right_)) 
#define BETWEEN00(_left_,_arg_,_right_) ((_left_ <  _arg_) && (_arg_ <  _right_)) 




void str_table_init(void){
	uint32_t i;
	uint32_t x,y;
	for (i = 0;i < 16;i++) {
		str_table[i] = 0;
	}
	for (i = 0; i < 256; i++) {
		x = i % 16;
		y = i / 16;
		if (BETWEEN11('a',i,'z') ||
			BETWEEN11('A',i,'Z') ||
			BETWEEN11('0',i,'9') ||
			(i == '.') ||
			(i == ' ')) {
			str_table[y] |= (1 << x);
		}
	}
	printf("{\r\n");
	for (i = 0;i < 15;i++) {
		printf("0x%04X,",str_table[i]);
		if ((i + 1) % 4 == 0) {
			printf("\r\n");
		}
	}
	printf("0x%04X}\r\n",str_table[i]);
}


uint32_t is_valid_str_char(uint8_t data){
	return (str_table[data >> 4] & (1 << (data & 0x0F)))? 1:0;
}

void str_table_test(void){
	uint32_t i;
	for (i = 0;i < 256;i++) {
		printf("%02x,%c,%d\r\n",i,i,is_valid_str_char(i));
	}
}


int main (int argc, char *argv[])
{
	str_table_init();
	str_table_test();
	return(0);
}

